﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCDto.Common.Banner;
using BCService.Common.Banner;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BCTMSRESTful.Controllers.Anonymous
{
    [Route("api/v1/[controller]")]
    [ApiController]
    public class BannerController : BCTMSRESTfulAPIController
    {
        private readonly IBannerTagcodeService bannerTagcodeService;
        private readonly IBannerService bannerService;

        public BannerController(IBannerTagcodeService bannerTagcodeService,IBannerService bannerService)
        {
            this.bannerTagcodeService = bannerTagcodeService;
            this.bannerService = bannerService;
        }

        /// <summary>
        /// 获取Banner分类编码信息列表。
        /// </summary>
        /// <response code="200">返回Banner分类编码信息列表</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(IEnumerable<BannerTagcodeDto>), 200)]
        [AllowAnonymous]
        public IActionResult TagCodes()
        {
            return this.Ok(this.bannerTagcodeService.GetList());
        }

        /// <summary>
        /// 获取Banner信息列表。
        /// </summary>
        /// <param name="bannerTagcode">Banner分类编码</param>
        /// <response code="200">返回Banner信息列表</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(IEnumerable<BannerDto>), 200)]
        [AllowAnonymous]
        public IActionResult Get([FromQuery(Name = "banner_tagcode")]string bannerTagcode)
        {
            return this.Ok(this.bannerService.Get(bannerTagcode));
        }
    }
}
